using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using Cysharp.Threading.Tasks;
using DG.Tweening;

namespace FpFrame
{
    
    public enum UIAnimationType
    {
        Default,
        None,
        Fade,
        Scale,
        Move,
        ShaderTransition
    }

    [System.Serializable]
    public struct UIViewAnimationConfig
    {
        public UIAnimationType[] showAnimations;   // Show 动画序列
        public UIAnimationType[] hideAnimations;   // Hide 动画序列
        public bool enableShaderTransition;        // 是否启用 Shader 过渡
        public TransitionSO transitionSO;          // Shader 特效配置
    }

    
    [RequireComponent(typeof(CanvasGroup))]
    public abstract class UIView : MonoBehaviour
    {
        public virtual UILayer Layer => UILayer.Normal;
        
        [Header("UI 动画配置 ")]
        public UIViewAnimationConfig animationConfig;
        
        public bool IsVisible { get; private set; }
     
        protected IResourceProvider resourceProvider;

        private CanvasGroup _canvasGroup;
        public CanvasGroup CanvasGroup => _canvasGroup ??= GetComponent<CanvasGroup>();
        
        public void InjectResourceProvider(IResourceProvider provider)
        {
            resourceProvider = provider;
        }

        // 生命周期
        public abstract void OnInit();
        
        public void SetVisible(bool visible) => IsVisible = visible;
    }
}